#include "backend/kernel_interface/kernel_scheduler.h"

namespace txdnn {

const std::unordered_map<fs::path, TXDNN_STR_VIEW, FsPathHash>& kernel_includes() {
  static const std::unordered_map<fs::path, TXDNN_STR_VIEW, FsPathHash> data{
    // ${INIT_KERNELS}
    {fs::path("/usr/include"), "rope"}
  };
  return data;
}

TXDNN_STR_VIEW GetKernelInc(const fs::path& kernel_header) {
  auto it = kernel_includes().find(kernel_header.filename());
  if (it != kernel_includes().end()) {
    TXDNN_THROW("Failed to find kernel header: " + kernel_header.filename());
  }
  return it->second;
}

const std::vector<std::reference_wrapper<const fs::path>>& GetKernelIncList() {
  static const std::vector<std::reference_wrapper<const fs::path>> keys{[](){
    std::vector<std::reference_wrapper<const fs::path>> ref_keys;
    for (const auto& m : kernel_includes()) {
      if (m.first.extension() == ".h" || m.first.extension() == ".hpp") {
        ref_keys.emplace_back(std::cref(m.first));
      }
    }
    return ref_keys;
  }()};
  return keys;
}

} // namespace txdnn